import axios from "axios";
import http from "@/api/http.js";
const baseUrl = "http://localhost:8091";
const testingProjectRequest={
    // 分页查询
    loadTestingProject(testingProject,page=1,limit=10,callBack){
        let url = baseUrl + "/testingProject/selectAll?page=" + page + "&limit=" + limit;
        if (testingProject){
            if (testingProject.testingProjectName){
                url += "&testingProjectName=" + testingProject.testingProjectName;
            }
            if (testingProject.testingProjectType){
                url += "&testingProjectType=" + testingProject.testingProjectType;
            }
        }
        axios.get(url,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callBack(res.data);
        })
    },
    // 导出数据
    exportTestingProject(testingProject,page=1,limit=10,callBack){
        let url = baseUrl + "/testingProject/export?page=" + page + "&limit=" + limit;
        if (testingProject){
            if (testingProject.testingProjectName){
                url += "&testingProjectName=" + testingProject.testingProjectName;
            }
            if (testingProject.testingProjectType){
                url += "&testingProjectType=" + testingProject.testingProjectType;
            }
        }
        axios.get(url,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callBack(res.data);
        })
    },
//     新增数据
    loadAddTestingProject(testingProject,callBack){
        let url = baseUrl + "/testingProject/add";
        axios.post(url,testingProject,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callBack(res.data);
        })
    },
//     根据id查询数据信息
    loadSelectByIdTestingProject(testingProjectId,callBack){
        let url = baseUrl + "/testingProject/selectById?testingProjectId=" + testingProjectId;
        axios.get(url,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callBack(res.data);
        })
    },
//     根据id修改数据信息
    loadUpdateTestingProject(testingProject,callBack){
        let url = baseUrl + "/testingProject/update";
        axios.post(url,testingProject,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callBack(res.data);
        })
    },
//     根据id删除数据信息
    loadDeleteTestingProjectById(testingProjectId,callBack){
        let url = baseUrl + "/testingProject/delete?testingProjectId=" + testingProjectId;
        axios.delete(url,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callBack(res.data);
        })
    },
//     根据检测模版id查询检测项数据信息
    loadSelectByTemplateId(templateId,callBack){
        let url = baseUrl + "/testingProject/selectByTemplateId?testingProjectTemplateId=" + testingProjectTemplateId;
        axios.get(url,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callBack(res.data);
        })
    }
}
export default testingProjectRequest